package view;

import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.BorderFactory;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Point;
import javax.swing.SwingConstants;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JTable;

import common.loadData;

public class addComplaintType extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JLabel lbComplaint = null;
	private JPanel jPanel = null;
	private JLabel icon = null;
	private JLabel lbName = null;
	private JTextField txtTypeComplaint = null;
	private JButton btnCancel = null;
	private JTable TableComplaint_type = null;
	private JButton btnAdd = null;

	public addComplaintType() {
		super();
		initialize();
	}

	private void initialize() {
		this.setSize(531, 401);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/image/List.png")));
		this.setResizable(false);
		this.setName("AddcomplaintType");
		this.setContentPane(getJContentPane());
		this.setTitle("Complaint Type");
	}

	private JPanel getJContentPane() {
		if (jContentPane == null) {
			lbName = new JLabel();
			lbName.setFont(new Font("Dialog", Font.BOLD, 14));
			lbName.setBounds(new Rectangle(121, 57, 85, 30));
			lbName.setText("Name Type:");
			icon = new JLabel();
			icon.setBounds(new Rectangle(14, 17, 77, 73));
			icon.setIcon(new ImageIcon(getClass().getResource("/image/add.png")));
			icon.setText("");
			lbComplaint = new JLabel();
			lbComplaint.setFont(new Font("Dialog", Font.BOLD, 18));
			lbComplaint.setForeground(new Color(8, 66, 36));
			lbComplaint.setSize(new Dimension(142, 28));
			lbComplaint.setLocation(new Point(0, 0));
			lbComplaint.setText("Complaint Type");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(getJPanel(), null);
			jContentPane.add(icon, null);
			jContentPane.add(getBtnCancel(), null);
			jContentPane.add(getTableComplaint_type(), null);
			jContentPane.add(getTxtTypeComplaint(), null);
			jContentPane.add(getBtnAdd(), null);
			jContentPane.add(lbName, null);
		}
		return jContentPane;
	}

	private JPanel getJPanel() {
		if (jPanel == null) {
			jPanel = new JPanel();
			jPanel.setLayout(null);
			jPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 2, 0, Color.red));
			jPanel.setSize(new Dimension(140, 29));
			jPanel.setLocation(new Point(129, 17));
			jPanel.add(lbComplaint, null);
		}
		return jPanel;
	}

	private JTextField getTxtTypeComplaint() {
		if (txtTypeComplaint == null) {
			txtTypeComplaint = new JTextField();
			txtTypeComplaint.setBounds(new Rectangle(224, 59, 159, 28));
		}
		return txtTypeComplaint;
	}

	private JButton getBtnCancel() {
		if (btnCancel == null) {
			btnCancel = new JButton();
			btnCancel.setLocation(new Point(406, 332));
			btnCancel.setText("Close");
			btnCancel.setHorizontalAlignment(SwingConstants.LEFT);
			btnCancel.setHorizontalTextPosition(SwingConstants.RIGHT);
			btnCancel.setIcon(new ImageIcon(getClass().getResource("/image/Close.png")));
			btnCancel.setSize(new Dimension(95, 28));
			btnCancel.addActionListener(new ActionListener() {
				
				@Override
				public void actionPerformed(ActionEvent e) {
					loadData.tab=5;
					mainForm a = new mainForm();
					a.setVisible(true);	
					dispose();
					
				}
			});
		}
		return btnCancel;
	}

	private JTable getTableComplaint_type() {
		if (TableComplaint_type == null) {
						String[] columnNames = {
					"No",
					"Name",
					"Last update",
					}; 
			Object[][] data = {
					{"1", "xa hoi","07/08/2011"},
					{"1", "ma tuy","17/05/2011"},
					{"1", "mat cua","23/03/2011"}
					}; 
			TableComplaint_type = new JTable(data,columnNames);
			TableComplaint_type.setBounds(new Rectangle(29, 105, 464, 214));

		}
		return TableComplaint_type;
	}

	private JButton getBtnAdd() {
		if (btnAdd == null) {
			btnAdd = new JButton();
			btnAdd.setHorizontalTextPosition(SwingConstants.RIGHT);
			btnAdd.setIcon(new ImageIcon(getClass().getResource("/image/OK.png")));
			btnAdd.setText("Add");
			btnAdd.setSize(new Dimension(91, 28));
			btnAdd.setLocation(new Point(403, 59));
			btnAdd.setHorizontalAlignment(SwingConstants.LEFT);
		}
		return btnAdd;
	}

}
